package com.gx.mxbbx.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.dao.RolesMapper;
import com.gx.mxbbx.po.Roles;
import com.gx.mxbbx.po.SysUser;
import com.gx.mxbbx.service.RolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.List;

@Service
@Transactional
public class RolesServiceImpl implements RolesService {
    @Autowired
    private RolesMapper rolesMapper;

    @Override
    public PageInfo<Roles> getRolesList(String roleName, Integer currentPage, Integer limit) {
        PageHelper.startPage(currentPage, limit);
        List<Roles> list = rolesMapper.getRolesList(roleName);
        PageInfo<Roles> pageInfo = new PageInfo<Roles>(list);
        return pageInfo;
    }

    //添加
    public void getroleadd(Roles roles) {
        roles.setCreateTime(new Timestamp(System.currentTimeMillis()));
        roles.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        rolesMapper.getroleadd(roles);
    }

    //删除
    public void roledelete(Integer id) {
        rolesMapper.roledelete(id);
    }


    public Roles getroleById(Integer id) {
        Roles roles = rolesMapper.getroleById(id);
        return roles;
    }

    public void rolesedit(Roles roles) {
        roles.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        rolesMapper.rolesedit(roles);
    }

}
